Adress comments

 * move file extension addition outside of function
 * move log statement before function call