still trying to get slopes to work. refactored the code to check less conditions