fix layout and image return functions