Fixing bug in photometry functions