lots of changes, main functions working now