removed duplicated code
shortened some code
always use file info