removed unneccesary static_cast, cleand up a bit