added y boundary checking and modified x boundary checking in string output functions