fixed bug with fits metadata, where the last key was not captured