revert
Revert "revert"

This reverts commit 4bb6381b5eb1da453b5a3ed0fa653332ed2fb4a9.
Revert "Revert "revert""

This reverts commit bc3caf45cac898392cc763d2d90617de8c2176ab.
Refactor using functions