huge changes. major functions implemented