added valid position func to simplify file