Removing duplicate code and keeping File API consistent