some changes to implementation