refactoring functions in openimgs