Fixed two issues I encountered using the snippet

Thank you for sharing this. Here comes my tit-for-tat response.