Refactored some usefull function