bugfix: code reorganizaiton