add border conditions