added final functionality and fixed bugs