major things working, could be refactored