added if condition for reading pictures