Made many changes, code not completely working