Fixed some indentations / code structure and added lightness component to z value