moved code logic to callling function & indent fix