Some functionality added, not working quite right