removed unused functions and fix error with incorrect pixels