made better masking algorithm
created get_position and implemented in main