Implemented the bypos function