diff --git a/projects/saf_r/shaders/raytracing.comp b/projects/saf_r/shaders/raytracing.comp
index 6bc4e6b9cea8999bc48ddb5ce1fe94c8d12e21de..95636f39b76a88364024f8e6c7c0b5c42fc6db12 100644
--- a/projects/saf_r/shaders/raytracing.comp
+++ b/projects/saf_r/shaders/raytracing.comp
@@ -36,13 +36,14 @@ layout(std430, binding = 2) coherent buffer spheres{
 
 layout(set=0, binding=3, rgba8) uniform image2D outImage;
 
-
+const int sphereCount = 4;
+const int lightCount  = 3;
 
 vec3 safr_reflect(const vec3 dir, const vec3 hit_center) {
     return dir - hit_center * 2.f * (dot(dir, hit_center));
 }
 
-bool ray_intersect(const vec3 origin, const vec3 dir, float t0, int id){
+bool ray_intersect(const vec3 origin, const vec3 dir, out float t0, const int id){
         vec3 L = inSpheres[id].center - origin;
         float tca = dot(L, dir);
         float d2 = dot(L, L) - tca * tca;
@@ -61,10 +62,10 @@ bool ray_intersect(const vec3 origin, const vec3 dir, float t0, int id){
         return true;
 }
 
-int sceneIntersect(const vec3 orig, const vec3 dir, vec3 hit, vec3 hit_center, Material material) {
+int sceneIntersect(const vec3 orig, const vec3 dir, out vec3 hit, out vec3 hit_center, out Material material) {
     float spheres_dist = 1.0 / 0.0;
     int index = -1;
-    for (int i = 0; i < inSpheres.length(); i++) {
+    for (int i = 0; i < sphereCount; i++) {
         float dist_i;
         if (ray_intersect(orig, dir, dist_i, i) && dist_i < spheres_dist) {
             spheres_dist = dist_i;
@@ -84,7 +85,6 @@ int sceneIntersect(const vec3 orig, const vec3 dir, vec3 hit, vec3 hit_center, M
 
 vec3 castRay(const vec3 orig, const vec3 dir, int max_depth) {
 
-    // max depth is 5
     int depth = 0;
     vec3 point, hit_center;
     Material material;
@@ -94,7 +94,7 @@ vec3 castRay(const vec3 orig, const vec3 dir, int max_depth) {
     vec3 reflect_dir = direction;
     vec3 reflect_orig = orig;
 
-    for(int i = 0; i < depth;i++){
+    for(int i = 0; i < max_depth;i++){
         depth++;
         intersect = sceneIntersect(reflect_orig, reflect_dir, point, hit_center, material);
         if(intersect != -1){
@@ -113,7 +113,7 @@ vec3 castRay(const vec3 orig, const vec3 dir, int max_depth) {
             //compute shadows and other light properties for the returned ray color
             float diffuse_light_intensity = 0, specular_light_intensity = 0;
 
-            for (int i = 0; i < inLights.length(); i++) {
+            for (int i = 0; i < lightCount; i++) {
                 vec3 light_dir = normalize(inLights[i].position - point);
                 float light_distance = distance(inLights[i].position, point);