cleaned up parse with where
split functions between files