Added some code from lpaste