Adapted code to coding guidelines