added function for detecting position inside page