most of the functionality done