Revert "refactor code"

This reverts commit d1d8abeb8202f54f29c774c377cc11790ce24124.
actual fix to a0fe7d6e2dd5ec2863992f75ad8c05576304abd6