using sychronization to remove layout problems
retrieving indeces correctly