refactored everything, added p controller